/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.djdb.shop;

import java.io.Serializable;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Transient;
/**
* @author Lieven Roegiers
* @copyright 2013
* @from MY_SHOP
*/
@Entity
@NamedQueries({
    @NamedQuery(name="Product.findAll",query="SELECT p FROM Product p"),
    @NamedQuery(name="Product.findBySerialnr",query="SELECT p FROM Product p WHERE p.serialnr = :serialnr"),
    @NamedQuery(name="Product.findByProductName",query="SELECT p FROM Product p WHERE p.name = :productname"),
})
public class Product implements Serializable{
    @Id
    private Long id;
    @Transient
    private StringProperty serialnr = new SimpleStringProperty();
    //private ReadOnlyStringWrapper serialnr = new ReadOnlyStringWrapper();
    /* public ReadOnlyStringProperty getReadSerialnrPropery(){
            return  serialnr.getReadOnlyProperty();
       }*/
    
    
    @Transient
    private StringProperty name = new SimpleStringProperty();
    
    @Lob
    @Basic(fetch=FetchType.LAZY)
    private byte[] photo;
    
    public String getSerialnr() {
        return serialnr.get();
    }
    private void setSerialnr(String Serialnr) {
        this.serialnr.set(Serialnr);
    }

    public String getName() {
        return name.get();
    }
    public void setName(String name) {
        this.name.set(name);
    }
    public StringProperty serialnr (){
       return serialnr;
    }
    public byte[] getPhoto(){
        return photo;
    }
    public void setPhotourl(byte[] photourl) {
        this.photo = photo;
    }      
    public Long getId() {
        return id;
    }
    public void setId(Long id){
        this.id = id;
    }
}
